using CustomListView;
using Microsoft.Office.Interop.Excel;
using SM.core;
using SS;
using System;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Printing;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace KM
{
	public class frmPoint : Form
	{
		private IContainer components = null;
		private System.Windows.Forms.Button btnClose;
		private DateTimePicker dtpDate;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Button btnAdd;
		private ListViewEx listViewMain;
		private System.Windows.Forms.Button btnSave;
		private System.Windows.Forms.Button btnSee;
		private System.Windows.Forms.Button btnEdit;
		private PrintDocument printDocument1;
		private SaveFileDialog sfdExportToExcel;
		private System.Windows.Forms.Button btnExportExcel;
		private System.Windows.Forms.Button btnDel;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label lblCurrDay;
		private string studentIDcurr = "";
		private StringCollection listStatus = new StringCollection();
		private SM.core.Point objPoint = new SM.core.Point();
		private bool CheckAddPage = false;
		public string FullName = "";
		private int PageNumber = 0;
		private string[] listDay = new string[100];
		private string[] listDayHeader = new string[100];
		private TextDocument doc;
		private Func objFun = new Func();
		private int indexPoint = 0;
		private int Number = 7;
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			ListViewItem listViewItem = new ListViewItem("");
			ListViewItem listViewItem2 = new ListViewItem("");
			ListViewItem listViewItem3 = new ListViewItem("");
			ListViewItem listViewItem4 = new ListViewItem("");
			ListViewItem listViewItem5 = new ListViewItem("");
			ListViewItem listViewItem6 = new ListViewItem("");
			ListViewItem listViewItem7 = new ListViewItem("");
			ListViewItem listViewItem8 = new ListViewItem("");
			ListViewItem listViewItem9 = new ListViewItem("");
			ListViewItem listViewItem10 = new ListViewItem("");
			ListViewItem listViewItem11 = new ListViewItem("");
			ListViewItem listViewItem12 = new ListViewItem("");
			ListViewItem listViewItem13 = new ListViewItem("");
			ListViewItem listViewItem14 = new ListViewItem("");
			ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(frmPoint));
			this.btnDel = new System.Windows.Forms.Button();
			this.btnEdit = new System.Windows.Forms.Button();
			this.btnSee = new System.Windows.Forms.Button();
			this.btnAdd = new System.Windows.Forms.Button();
			this.label1 = new System.Windows.Forms.Label();
			this.dtpDate = new DateTimePicker();
			this.btnClose = new System.Windows.Forms.Button();
			this.btnSave = new System.Windows.Forms.Button();
			this.printDocument1 = new PrintDocument();
			this.sfdExportToExcel = new SaveFileDialog();
			this.btnExportExcel = new System.Windows.Forms.Button();
			this.listViewMain = new ListViewEx();
			this.label2 = new System.Windows.Forms.Label();
			this.lblCurrDay = new System.Windows.Forms.Label();
			base.SuspendLayout();
			this.btnDel.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnDel.BackColor = SystemColors.Control;
			this.btnDel.FlatStyle = FlatStyle.System;
			this.btnDel.Font = new System.Drawing.Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnDel.ImageAlign = ContentAlignment.MiddleLeft;
			this.btnDel.Location = new System.Drawing.Point(395, 568);
			this.btnDel.Name = "btnDel";
			this.btnDel.Size = new Size(80, 28);
			this.btnDel.TabIndex = 28;
			this.btnDel.Text = "Xoá";
			this.btnDel.UseVisualStyleBackColor = false;
			this.btnDel.Click += new EventHandler(this.btnDel_Click);
			this.btnEdit.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnEdit.BackColor = SystemColors.Control;
			this.btnEdit.FlatStyle = FlatStyle.System;
			this.btnEdit.Font = new System.Drawing.Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnEdit.ImageAlign = ContentAlignment.MiddleLeft;
			this.btnEdit.Location = new System.Drawing.Point(313, 568);
			this.btnEdit.Name = "btnEdit";
			this.btnEdit.Size = new Size(80, 28);
			this.btnEdit.TabIndex = 27;
			this.btnEdit.Text = "Sửa";
			this.btnEdit.UseVisualStyleBackColor = false;
			this.btnEdit.Click += new EventHandler(this.btnEdit_Click);
			this.btnSee.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnSee.BackColor = SystemColors.Control;
			this.btnSee.FlatStyle = FlatStyle.System;
			this.btnSee.Font = new System.Drawing.Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnSee.ImageAlign = ContentAlignment.MiddleLeft;
			this.btnSee.Location = new System.Drawing.Point(149, 568);
			this.btnSee.Name = "btnSee";
			this.btnSee.Size = new Size(80, 28);
			this.btnSee.TabIndex = 26;
			this.btnSee.Text = "Xem";
			this.btnSee.UseVisualStyleBackColor = false;
			this.btnSee.Click += new EventHandler(this.btnSee_Click);
			this.btnAdd.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnAdd.BackColor = SystemColors.Control;
			this.btnAdd.FlatStyle = FlatStyle.System;
			this.btnAdd.Font = new System.Drawing.Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnAdd.ImageAlign = ContentAlignment.MiddleLeft;
			this.btnAdd.Location = new System.Drawing.Point(231, 568);
			this.btnAdd.Name = "btnAdd";
			this.btnAdd.Size = new Size(80, 28);
			this.btnAdd.TabIndex = 25;
			this.btnAdd.Text = "Thêm ngày";
			this.btnAdd.UseVisualStyleBackColor = false;
			this.btnAdd.Click += new EventHandler(this.btnAdd_Click);
			this.label1.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.label1.AutoSize = true;
			this.label1.Font = new System.Drawing.Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.label1.Location = new System.Drawing.Point(7, 573);
			this.label1.Name = "label1";
			this.label1.Size = new Size(41, 15);
			this.label1.TabIndex = 22;
			this.label1.Text = "Ngày :";
			this.dtpDate.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.dtpDate.CalendarForeColor = Color.Blue;
			this.dtpDate.CustomFormat = "dd/MM/yyyy";
			this.dtpDate.Font = new System.Drawing.Font("Arial", 11.25f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.dtpDate.Format = DateTimePickerFormat.Custom;
			this.dtpDate.Location = new System.Drawing.Point(51, 569);
			this.dtpDate.Name = "dtpDate";
			this.dtpDate.Size = new Size(92, 25);
			this.dtpDate.TabIndex = 20;
			this.dtpDate.ValueChanged += new EventHandler(this.dtpDate_ValueChanged);
			this.btnClose.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);
			this.btnClose.BackColor = Color.FromArgb(192, 255, 255);
			this.btnClose.FlatStyle = FlatStyle.System;
			this.btnClose.Font = new System.Drawing.Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			//this.btnClose.ImageAlign = ContentAlignment.MiddleLeft;
			this.btnClose.Location = new System.Drawing.Point(806, 568);
			this.btnClose.Name = "btnClose";
			this.btnClose.Size = new Size(90, 28);
			this.btnClose.TabIndex = 19;
			this.btnClose.Text = "Th&oát [ESC]";
			this.btnClose.UseVisualStyleBackColor = false;
			this.btnClose.Click += new EventHandler(this.btnClose_Click);
			this.btnSave.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnSave.BackColor = SystemColors.Control;
			this.btnSave.Enabled = false;
			this.btnSave.FlatStyle = FlatStyle.System;
			this.btnSave.Font = new System.Drawing.Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnSave.ImageAlign = ContentAlignment.MiddleLeft;
			this.btnSave.Location = new System.Drawing.Point(477, 568);
			this.btnSave.Name = "btnSave";
			this.btnSave.Size = new Size(80, 28);
			this.btnSave.TabIndex = 21;
			this.btnSave.Text = "Ghi nhận";
			this.btnSave.UseVisualStyleBackColor = false;
			this.btnSave.Click += new EventHandler(this.btnSave_Click);
			this.btnExportExcel.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnExportExcel.BackColor = SystemColors.Control;
			this.btnExportExcel.FlatStyle = FlatStyle.System;
			this.btnExportExcel.Font = new System.Drawing.Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnExportExcel.ImageAlign = ContentAlignment.MiddleLeft;
			this.btnExportExcel.Location = new System.Drawing.Point(559, 568);
			this.btnExportExcel.Name = "btnExportExcel";
			this.btnExportExcel.Size = new Size(80, 28);
			this.btnExportExcel.TabIndex = 22;
			this.btnExportExcel.Text = "Xuất Excel";
			this.btnExportExcel.UseVisualStyleBackColor = false;
			this.btnExportExcel.Click += new EventHandler(this.btnExportExcel_Click);
			this.listViewMain.Activation = ItemActivation.OneClick;
			this.listViewMain.AllowColumnReorder = true;
			this.listViewMain.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
			this.listViewMain.BorderStyle = BorderStyle.FixedSingle;
			this.listViewMain.Cursor = Cursors.Hand;
			this.listViewMain.Font = new System.Drawing.Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.listViewMain.FullRowSelect = true;
			this.listViewMain.GridLines = true;
			this.listViewMain.Items.AddRange(new ListViewItem[]
			{
				listViewItem,
				listViewItem2,
				listViewItem3,
				listViewItem4,
				listViewItem5,
				listViewItem6,
				listViewItem7,
				listViewItem8,
				listViewItem9,
				listViewItem10,
				listViewItem11,
				listViewItem12,
				listViewItem13,
				listViewItem14
			});
			this.listViewMain.Location = new System.Drawing.Point(5, 34);
			this.listViewMain.Name = "listViewMain";
			this.listViewMain.Size = new Size(890, 528);
			this.listViewMain.TabIndex = 20;
			this.listViewMain.txtTextBox = null;
			this.listViewMain.UseCompatibleStateImageBehavior = false;
			this.listViewMain.View = View.Details;
			this.label2.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.label2.Font = new System.Drawing.Font("Arial", 9.75f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.label2.Location = new System.Drawing.Point(5, 9);
			this.label2.Name = "label2";
			this.label2.Size = new Size(890, 22);
			this.label2.TabIndex = 29;
			this.label2.Text = "BẢNG CHẤM CÔNG NHÂN VIÊN";
			this.label2.TextAlign = ContentAlignment.MiddleCenter;
			this.lblCurrDay.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
			this.lblCurrDay.Font = new System.Drawing.Font("Arial", 11.25f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.lblCurrDay.ForeColor = Color.FromArgb(0, 0, 192);
			this.lblCurrDay.Location = new System.Drawing.Point(645, 572);
			this.lblCurrDay.Name = "lblCurrDay";
			this.lblCurrDay.Size = new Size(155, 20);
			this.lblCurrDay.TabIndex = 30;
			this.lblCurrDay.TextAlign = ContentAlignment.MiddleLeft;
			base.AutoScaleDimensions = new SizeF(7f, 15f);
			//base.AutoScaleMode = AutoScaleMode.Font;
			base.ClientSize = new Size(900, 600);
			base.Controls.Add(this.lblCurrDay);
			base.Controls.Add(this.label2);
			base.Controls.Add(this.btnExportExcel);
			base.Controls.Add(this.btnSave);
			base.Controls.Add(this.btnClose);
			base.Controls.Add(this.listViewMain);
			base.Controls.Add(this.btnDel);
			base.Controls.Add(this.btnEdit);
			base.Controls.Add(this.btnSee);
			base.Controls.Add(this.btnAdd);
			base.Controls.Add(this.label1);
			base.Controls.Add(this.dtpDate);
			this.Font = new System.Drawing.Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			//base.Icon = (System.Drawing.Icon)componentResourceManager.GetObject("$this.Icon");
			//base.Icon = (System.Drawing.Icon)componentResourceManager.GetObject("$this.Icon");
			base.Name = "frmPoint";
			base.StartPosition = FormStartPosition.CenterScreen;
			this.Text = "frmListStudent";
			base.WindowState = FormWindowState.Maximized;
			base.Load += new EventHandler(this.frmListStudent_Load);
			base.SizeChanged += new EventHandler(this.frmListStudent_SizeChanged);
			base.ResumeLayout(false);
			base.PerformLayout();
		}
		public frmPoint()
		{
			this.InitializeComponent();
		}
		private void frmListStudent_Load(object sender, EventArgs e)
		{
			this.listViewMain.AddSubItem = true;
			this.listStatus.AddRange(new string[]
			{
				"Đi làm",
				"Vắng K.Phép",
				"Vắng C.phép",
				"Lý do khác"
			});
			this.btnSee.PerformClick();
			this.btnSave.Enabled = false;
		}
		private void frmListStudent_SizeChanged(object sender, EventArgs e)
		{
		}
		private void btnClose_Click(object sender, EventArgs e)
		{
			base.Close();
		}
		private void lsvStudent_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.studentIDcurr = this.listViewMain.Items[this.listViewMain.FocusedItem.Index].SubItems[1].Text;
		}
		private void btnAdd_Click(object sender, EventArgs e)
		{
			if (this.checkColumn() == -1)
			{
				this.btnSave.PerformClick();
				this.listViewMain.Columns.Add(this.dtpDate.Text, 86);
				for (int i = 0; i < this.listViewMain.Items.Count; i++)
				{
					this.listViewMain.Items[i].SubItems.Add("");
				}
				this.listViewMain.AddComboBoxCell(-1, this.listViewMain.Columns.Count - 1, this.listStatus);
				this.btnSave.Enabled = true;
			}
		}
		private int checkColumn()
		{
			int num = -1;
			this.lblCurrDay.Text = "";
			string text = this.dtpDate.Text;
			for (int i = 0; i < this.listViewMain.Columns.Count; i++)
			{
				if (text.Substring(0, 2) == this.listViewMain.Columns[i].Text.Substring(0, 2) && text.Substring(4, 2) == this.listViewMain.Columns[i].Text.Substring(4, 2) && text.Substring(6, 4) == this.listViewMain.Columns[i].Text.Substring(6, 4))
				{
					num = i;
				}
			}
			if (num != -1)
			{
				this.lblCurrDay.Text = "Ngày được chọn : " + this.listViewMain.Columns[num].Text;
			}
			else
			{
				this.lblCurrDay.Text = "";
			}
			return num;
		}
		private void btnSave_Click(object sender, EventArgs e)
		{
			try
			{
				int num = this.checkColumn();
				if (num != -1)
				{
					for (int i = 0; i < this.listViewMain.Items.Count; i++)
					{
						if (this.listViewMain.Items[i].SubItems[0].Text.Trim() != "")
						{
							this.objPoint.action(this.listViewMain.Items[i].SubItems[0].Text, this.listViewMain.Items[i].SubItems[1].Text.Replace("III", "3").Replace("II", "2").Replace("I", "1"), "", this.dtpDate.Value.ToShortDateString(), this.listViewMain.Items[i].SubItems[num].Text);
						}
					}
				}
				this.listViewMain.Refresh();
				this.btnSave.Enabled = false;
			}
			catch
			{
			}
		}
		private void releaseObject(object obj)
		{
			try
			{
				Marshal.ReleaseComObject(obj);
				obj = null;
			}
			catch (Exception ex)
			{
				obj = null;
				MessageBox.Show("Exception Occured while releasing object " + ex.ToString());
			}
			finally
			{
				GC.Collect();
			}
		}
		private void btnSee_Click(object sender, EventArgs e)
		{
			this.listViewMain.Columns.Clear();
			this.listDay = this.objPoint.listDay();
			this.listDayHeader = this.objPoint.listDayHeader();
			this.listViewMain.Columns.Add("ID", 0);
			this.listViewMain.Columns.Add("Họ và tên", 200);
			this.objPoint.loadToListView_Point(this.listViewMain);
			for (int i = 0; i < this.listDay.Length; i++)
			{
				if (this.listDay[i] != null)
				{
					this.listViewMain.Columns.Add(this.listDayHeader[i], 90);
					for (int j = 0; j < this.listViewMain.Items.Count; j++)
					{
						this.objPoint.fillToRow(DateTime.Parse(this.listDay[i].ToString()), this.listViewMain, this.listViewMain.Columns.Count, j);
					}
				}
			}
			this.listViewMain.Refresh();
			this.btnSave.Enabled = false;
		}
		private void dtpDate_ValueChanged(object sender, EventArgs e)
		{
			if (this.checkColumn() == -1)
			{
				this.btnEdit.Enabled = false;
			}
			else
			{
				this.btnEdit.Enabled = true;
			}
		}
		private void btnEdit_Click(object sender, EventArgs e)
		{
			if (this.checkColumn() != -1)
			{
				this.listViewMain.AddComboBoxCell(-1, this.checkColumn(), this.listStatus);
				this.btnSave.Enabled = true;
			}
		}
		private void btnPrint_Click(object sender, EventArgs e)
		{
			string[] text = new string[10];
			if (this.listViewMain.Items.Count > 0)
			{
				this.CheckAddPage = false;
				PrintDocument printDocument = new TextDocument(text);
				printDocument.PrintPage += new PrintPageEventHandler(this.printBill_PrintPage_Point);
				printDocument.DefaultPageSettings.Landscape = true;
				PaperSize paperSize = new PaperSize("A4", 827, 1169);
				printDocument.DefaultPageSettings.PaperSize = paperSize;
				new PrintPreviewDialog
				{
					WindowState = FormWindowState.Maximized,
					PrintPreviewControl = 
					{
						Zoom = 1.0
					},
					Document = printDocument
				}.ShowDialog();
			}
		}
		private void printBill_PrintPage_Point(object sender, PrintPageEventArgs e)
		{
			System.Drawing.Font font = new System.Drawing.Font("Arial", 12f, FontStyle.Bold);
			System.Drawing.Font font2 = new System.Drawing.Font("Arial", 10.5f);
			System.Drawing.Font font3 = new System.Drawing.Font("Arial", 14f, FontStyle.Bold);
			System.Drawing.Font font4 = new System.Drawing.Font("Arial", 12f);
			System.Drawing.Font font5 = new System.Drawing.Font("Arial", 11f);
			System.Drawing.Font font6 = new System.Drawing.Font("Arial", 9f, FontStyle.Bold);
			System.Drawing.Font font7 = new System.Drawing.Font("Arial", 9f, FontStyle.Italic);
			System.Drawing.Font font8 = new System.Drawing.Font("Arial", 10f, FontStyle.Italic);
			System.Drawing.Font font9 = new System.Drawing.Font("Arial", 12f, FontStyle.Bold);
			System.Drawing.Font font10 = new System.Drawing.Font("Arial", 10f, FontStyle.Bold);
			System.Drawing.Font font11 = new System.Drawing.Font("Arial", 10f);
			System.Drawing.Font font12 = new System.Drawing.Font("Arial", 9f);
			System.Drawing.Font font13 = new System.Drawing.Font("Arial", 11f, FontStyle.Bold);
			System.Drawing.Font font14 = new System.Drawing.Font("Arial", 12f, FontStyle.Italic);
			System.Drawing.Font font15 = new System.Drawing.Font("Arial", 10f);
			System.Drawing.Font font16 = new System.Drawing.Font("Arial", 10f, FontStyle.Bold);
			System.Drawing.Font font17 = new System.Drawing.Font("Arial", 17f, FontStyle.Bold);
			float num = (float)e.MarginBounds.Left;
			float num2 = (float)e.MarginBounds.Top;
			int num3 = 0;
			StringFormat stringFormat = new StringFormat();
			stringFormat.Alignment = StringAlignment.Far;
			StringFormat stringFormat2 = new StringFormat();
			stringFormat2.Alignment = StringAlignment.Center;
			float height = font3.GetHeight(e.Graphics);
			this.doc = (TextDocument)sender;
			this.doc.PageNumber++;
			num = (float)(e.MarginBounds.Left + 15);
			num2 += height;
			num2 += height;
			num2 += height;
			if (this.doc.PageNumber == 1)
			{
				num3 = 160;
			}
			else
			{
				num3 = 40;
			}
			e.Graphics.DrawRectangle(new Pen(Brushes.Black, 1f), new System.Drawing.Rectangle(50, num3, 1058, 50));
			e.Graphics.FillRectangle(Brushes.Aqua, new System.Drawing.Rectangle(50, num3, 1058, 49));
			e.Graphics.DrawLine(new Pen(Brushes.Black, 1f), new System.Drawing.Point(50, num3), new System.Drawing.Point(1108, num3));
			e.Graphics.DrawLine(new Pen(Brushes.Black, 1f), new System.Drawing.Point(50, num3), new System.Drawing.Point(50, num3 + 77));
			e.Graphics.DrawLine(new Pen(Brushes.Black, 1f), new System.Drawing.Point(80, num3), new System.Drawing.Point(80, num3 + 77));
			e.Graphics.DrawLine(new Pen(Brushes.Black, 1f), new System.Drawing.Point(280, num3), new System.Drawing.Point(280, num3 + 77));
			int num4 = 26;
			int num5 = num3 + 77;
			for (int i = 1; i <= 31; i++)
			{
				e.Graphics.DrawLine(new Pen(Brushes.Black, 1f), new System.Drawing.Point(280 + num4 * i, num3 + 25), new System.Drawing.Point(280 + num4 * i, num3 + 77));
			}
			for (int i = 2; i < this.listViewMain.Columns.Count; i++)
			{
				e.Graphics.DrawString(DateTime.Parse(this.listViewMain.Columns[i].Text).Day.ToString(), font7, Brushes.Black, (float)(256 + num4 * i), (float)(num3 + 32));
			}
			e.Graphics.DrawLine(new Pen(Brushes.Black, 1f), new System.Drawing.Point(280, num3), new System.Drawing.Point(280, num3 + 77));
			e.Graphics.DrawLine(new Pen(Brushes.Black, 1f), new System.Drawing.Point(1108, num3), new System.Drawing.Point(1108, num3 + 77));
			e.Graphics.DrawLine(new Pen(Brushes.Black, 1f), new System.Drawing.Point(280, num3 + 25), new System.Drawing.Point(1108, num3 + 25));
			num2 += height;
			num3 += 27;
			if (this.doc.PageNumber == 1)
			{
				e.Graphics.DrawString(this.objFun.getCompanyInfor("ComName").ToUpper(), font9, Brushes.Black, (float)(e.PageBounds.Width / 2), 40f, stringFormat2);
				e.Graphics.DrawString(this.objFun.getCompanyInfor("ComAddress"), font2, Brushes.Black, (float)(e.PageBounds.Width / 2), 60f, stringFormat2);
				e.Graphics.DrawString("Điện thoại : " + this.objFun.getCompanyInfor("ComPhone"), font2, Brushes.Black, (float)(e.PageBounds.Width / 2), 80f, stringFormat2);
				e.Graphics.DrawString("BẢNG CHẤM CÔNG NHÂN VIÊN", font3, Brushes.Black, (float)(e.PageBounds.Width / 2), 110f, stringFormat2);
				e.Graphics.DrawString("THÁNG " + this.dtpDate.Value.Month.ToString(), font10, Brushes.Black, (float)(e.PageBounds.Width / 2 + 100), 165f, stringFormat2);
			}
			int num6 = 0;
			if (this.doc.PageNumber == 1)
			{
				num6 = e.MarginBounds.Bottom - 30;
			}
			else
			{
				num6 = e.MarginBounds.Bottom + 125;
			}
			e.Graphics.DrawString("TT", font6, Brushes.Black, num - 60f, (float)(num3 - 10));
			e.Graphics.DrawString("Họ và tên", font6, Brushes.Black, num + 20f, (float)(num3 - 10));
			e.Graphics.DrawString("", font6, Brushes.Black, num + 550f, (float)(num3 - 45));
			while (num2 < (float)num6 && this.doc.Offset < this.listViewMain.Items.Count)
			{
				e.Graphics.DrawLine(new Pen(Brushes.Black, 1f), new System.Drawing.Point(50, num3 + 45), new System.Drawing.Point(1108, num3 + 45));
				e.Graphics.DrawLine(new Pen(Brushes.Black, 1f), new System.Drawing.Point(50, num3), new System.Drawing.Point(50, num3 + 45));
				e.Graphics.DrawLine(new Pen(Brushes.Black, 1f), new System.Drawing.Point(80, num3), new System.Drawing.Point(80, num3 + 45));
				e.Graphics.DrawLine(new Pen(Brushes.Black, 1f), new System.Drawing.Point(280, num3), new System.Drawing.Point(280, num3 + 45));
				e.Graphics.DrawLine(new Pen(Brushes.Black, 1f), new System.Drawing.Point(1108, num3), new System.Drawing.Point(1108, num3 + 45));
				if (this.listViewMain.Items[this.doc.Offset].SubItems[1].Text.Trim() != "I" && this.listViewMain.Items[this.doc.Offset].SubItems[1].Text.Trim() != "II" && this.listViewMain.Items[this.doc.Offset].SubItems[1].Text.Trim() != "III")
				{
					this.indexPoint++;
					e.Graphics.DrawString(this.indexPoint.ToString(), font12, Brushes.Black, num - 60f, (float)(num3 + 24));
					e.Graphics.DrawString(this.listViewMain.Items[this.doc.Offset].SubItems[1].Text, font11, Brushes.Black, num - 30f, (float)(num3 + 24));
				}
				else
				{
					if (this.listViewMain.Items[this.doc.Offset].SubItems[1].Text.Trim() == "III" && this.indexPoint % 6 == 0)
					{
						e.Graphics.DrawString(this.listViewMain.Items[this.doc.Offset].SubItems[1].Text, font11, Brushes.Black, num + 170f, (float)(num3 - 254));
					}
					else
					{
						e.Graphics.DrawString(this.listViewMain.Items[this.doc.Offset].SubItems[1].Text, font11, Brushes.Black, num + 170f, (float)num3);
					}
				}
				if (this.listViewMain.Items[this.doc.Offset].SubItems[1].Text.Trim() == "III")
				{
					num3 -= 24;
				}
				for (int i = 1; i <= 31; i++)
				{
					e.Graphics.DrawLine(new Pen(Brushes.Black, 1f), new System.Drawing.Point(280 + num4 * i, num3 + 22), new System.Drawing.Point(280 + num4 * i, num3 + 45));
				}
				for (int i = 2; i < this.listViewMain.Columns.Count; i++)
				{
					try
					{
						if (this.listViewMain.Items[this.doc.Offset].SubItems[1].Text == "III")
						{
							if (this.indexPoint % 6 != 0)
							{
								e.Graphics.DrawString(this.listViewMain.Items[this.doc.Offset].SubItems[i].Text.Replace("Đi làm", "V").Replace("Vắng K.Phép", "O").Replace("Vắng C.phép", "V-").Replace("Lý do khác", "X"), font8, Brushes.Black, (float)(259 + num4 * i), (float)(num3 + 24));
							}
							else
							{
								e.Graphics.DrawString(this.listViewMain.Items[this.doc.Offset].SubItems[i].Text.Replace("Đi làm", "V").Replace("Vắng K.Phép", "O").Replace("Vắng C.phép", "V-").Replace("Lý do khác", "X"), font8, Brushes.Black, (float)(259 + num4 * i), (float)num3);
							}
						}
						else
						{
							e.Graphics.DrawString(this.listViewMain.Items[this.doc.Offset].SubItems[i].Text.Replace("Đi làm", "V").Replace("Vắng K.Phép", "O").Replace("Vắng C.phép", "V-").Replace("Lý do khác", "X"), font8, Brushes.Black, (float)(259 + num4 * i), (float)num3);
						}
					}
					catch
					{
					}
				}
				this.doc.Offset++;
				num2 += height;
				num3 += 24;
			}
			this.PageNumber++;
			num2 = (float)(e.MarginBounds.Bottom + 30);
			if (this.doc.Offset == 9)
			{
				if (e.MarginBounds.Bottom > 40)
				{
					e.Graphics.DrawString(string.Concat(new string[]
					{
						"Ngày ",
						DateTime.Now.Day.ToString(),
						" tháng ",
						DateTime.Now.Month.ToString(),
						" năm ",
						DateTime.Now.Year.ToString()
					}), font15, Brushes.Black, num + 762f, (float)(e.MarginBounds.Bottom - 70));
					num2 += height;
					e.Graphics.DrawString("Quản lý", font16, Brushes.Black, num + 150f, (float)(e.MarginBounds.Bottom - 70));
					e.Graphics.DrawString("Người lập báo cáo", font16, Brushes.Black, num + 790f, (float)(e.MarginBounds.Bottom - 70));
					num2 += height;
					num2 += height;
					num2 += 8f;
					e.Graphics.DrawString(this.FullName, font15, Brushes.Black, num + 790f, (float)e.MarginBounds.Bottom);
					e.Graphics.DrawString("Ghi chú - V : Đi làm    \t\tV- : Vắng có phép    \t\tO : Vắng không lý do    \t\tX : Lý do khác", font13, Brushes.Black, (float)(e.PageBounds.Width / 2), (float)(e.MarginBounds.Bottom + 40), stringFormat2);
				}
				else
				{
					e.HasMorePages = true;
					this.CheckAddPage = true;
					e.Graphics.DrawString("Ghi chú - V : Đi làm    \t\tV- : Vắng có phép    \t\tO : Vắng không lý do    \t\tX : Lý do khác", font13, Brushes.Black, (float)(e.PageBounds.Width / 2), (float)(e.MarginBounds.Bottom + 40), stringFormat2);
				}
			}
			stringFormat.Alignment = StringAlignment.Near;
			e.Graphics.DrawString("Trang " + this.PageNumber.ToString(), font12, Brushes.Black, num + 840f, num2, stringFormat);
			if (this.indexPoint < 7)
			{
				e.HasMorePages = true;
			}
			else
			{
				this.doc.Offset = 0;
				this.doc.PageNumber = 0;
				this.PageNumber = 0;
			}
		}
		private void cbbShift_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.btnSee.PerformClick();
		}
		private void btnExportExcel_Click(object sender, EventArgs e)
		{
			if (this.listViewMain.Items.Count > 0)
			{
				this.sfdExportToExcel.Filter = "Excel 97 - 2003 files (*.xls)|*.xls|Excel 2007 files (*.xlsx)|*.xlsx";
				this.sfdExportToExcel.FilterIndex = 1;
				this.sfdExportToExcel.RestoreDirectory = true;
				this.sfdExportToExcel.FileName = "";
				if (this.sfdExportToExcel.ShowDialog() == DialogResult.OK && this.sfdExportToExcel.FileName != "")
				{
					string fileName = this.sfdExportToExcel.FileName;
					try
					{
						this.Cursor = Cursors.WaitCursor;
						object value = Missing.Value;
						Microsoft.Office.Interop.Excel.Application application = new ApplicationClass();
						Workbook workbook = application.Workbooks.Add(value);
						this.Number = 5;
						this.PrintList(workbook);
						workbook.SaveCopyAs("" + fileName);
						workbook.Close(false, value, value);
						application.Quit();
						this.releaseObject(workbook);
						this.releaseObject(application);
						this.Cursor = Cursors.Default;
						MessageBox.Show("Xuất file Excel thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
					}
					catch
					{
						MessageBox.Show("Có lỗi xảy ra trong quá trình xuất dữ liệu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Hand);
					}
				}
			}
			else
			{
				MessageBox.Show("Không có mục nào được chọn.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
			}
		}
		private void PrintList(Workbook xlWorkBook)
		{
			Worksheet worksheet = null;
			try
			{
				worksheet = (Worksheet)xlWorkBook.Worksheets.get_Item(1);
			}
			catch
			{
			}
			worksheet.PageSetup.Orientation = XlPageOrientation.xlLandscape;
			worksheet.PageSetup.LeftMargin = 2.5;
			worksheet.PageSetup.RightMargin = 0.0;
			((Range)worksheet.Columns["A", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["B", Type.Missing]).ColumnWidth = 22.5;
			((Range)worksheet.Columns["C", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["D", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["E", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["F", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["G", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["H", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["I", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["J", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["K", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["L", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["M", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["N", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["O", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["P", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["Q", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["R", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["S", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["T", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["U", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["V", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["W", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["X", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["Y", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["Z", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["AA", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["AB", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["AC", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["AD", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["AE", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["AF", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["AG", Type.Missing]).ColumnWidth = 2.5;
			((Range)worksheet.Columns["AH", Type.Missing]).ColumnWidth = 2.5;
			worksheet.get_Range("A1", "AH1").Merge(false);
			Range range = worksheet.get_Range("A1", "AH1");
			range.FormulaR1C1 = this.objFun.getCompanyInfor("ComName").ToUpper();
			range.HorizontalAlignment = 3;
			range.VerticalAlignment = 3;
			range.Font.Size = 13;
			range.Font.Bold = true;
			worksheet.get_Range("A2", "AH2").Merge(false);
			range = worksheet.get_Range("A2", "AH2");
			range.FormulaR1C1 = this.objFun.getCompanyInfor("ComAddress");
			range.HorizontalAlignment = 3;
			range.VerticalAlignment = 3;
			range.Font.Size = 11;
			worksheet.get_Range("A3", "AH3").Merge(false);
			range = worksheet.get_Range("A3", "AH3");
			range.FormulaR1C1 = "Điện thoại : " + this.objFun.getCompanyInfor("ComPhone");
			range.HorizontalAlignment = 3;
			range.VerticalAlignment = 3;
			range.Font.Size = 11;
			worksheet.get_Range("A5", "AH5").Merge(false);
			range = worksheet.get_Range("A5", "AH5");
			range.FormulaR1C1 = "BẢNG CHẤM CÔNG NHÂN VIÊN";
			range.HorizontalAlignment = 3;
			range.VerticalAlignment = 3;
			range.Font.Size = 13;
			range.Font.Bold = true;
			worksheet.get_Range("A" + (this.Number + 2).ToString(), "A" + (this.Number + 3).ToString()).Merge(false);
			range = worksheet.get_Range("A" + (this.Number + 2).ToString(), "A" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "TT";
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			worksheet.get_Range("B" + (this.Number + 2).ToString(), "B" + (this.Number + 3).ToString()).Merge(false);
			range = worksheet.get_Range("B" + (this.Number + 2).ToString(), "B" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "Họ và tên";
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			worksheet.get_Range("C" + (this.Number + 2).ToString(), "AH" + (this.Number + 2).ToString()).Merge(false);
			range = worksheet.get_Range("C" + (this.Number + 2).ToString(), "AH" + (this.Number + 2).ToString());
			range.FormulaR1C1 = "THÁNG " + this.dtpDate.Value.Month.ToString();
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range.Font.Size = 12;
			range.Font.Bold = true;
			range = worksheet.get_Range("C" + (this.Number + 3).ToString(), "C" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "Ca";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("D" + (this.Number + 3).ToString(), "D" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "1";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("E" + (this.Number + 3).ToString(), "E" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "2";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("F" + (this.Number + 3).ToString(), "F" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "3";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("G" + (this.Number + 3).ToString(), "G" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "4";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("H" + (this.Number + 3).ToString(), "H" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "5";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("I" + (this.Number + 3).ToString(), "I" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "6";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("J" + (this.Number + 3).ToString(), "J" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "7";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("K" + (this.Number + 3).ToString(), "K" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "8";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("L" + (this.Number + 3).ToString(), "L" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "9";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("M" + (this.Number + 3).ToString(), "M" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "10";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("N" + (this.Number + 3).ToString(), "N" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "11";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("O" + (this.Number + 3).ToString(), "O" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "12";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("P" + (this.Number + 3).ToString(), "P" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "13";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("Q" + (this.Number + 3).ToString(), "Q" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "14";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("R" + (this.Number + 3).ToString(), "R" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "15";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("S" + (this.Number + 3).ToString(), "S" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "16";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("T" + (this.Number + 3).ToString(), "T" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "17";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("U" + (this.Number + 3).ToString(), "U" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "18";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("V" + (this.Number + 3).ToString(), "V" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "19";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("W" + (this.Number + 3).ToString(), "W" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "20";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("X" + (this.Number + 3).ToString(), "X" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "21";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("Y" + (this.Number + 3).ToString(), "Y" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "22";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("Z" + (this.Number + 3).ToString(), "Z" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "23";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("AA" + (this.Number + 3).ToString(), "AA" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "24";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("AB" + (this.Number + 3).ToString(), "AB" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "25";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("AC" + (this.Number + 3).ToString(), "AC" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "26";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("AD" + (this.Number + 3).ToString(), "AD" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "27";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("AE" + (this.Number + 3).ToString(), "AE" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "28";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("AF" + (this.Number + 3).ToString(), "AF" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "29";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("AG" + (this.Number + 3).ToString(), "AG" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "30";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("AH" + (this.Number + 3).ToString(), "AH" + (this.Number + 3).ToString());
			range.FormulaR1C1 = "31";
			range.Font.Size = 10;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("A" + (this.Number + 2).ToString(), "AH" + (this.Number + 3).ToString());
			range.Font.Name = "Arial";
			range.HorizontalAlignment = XlHAlign.xlHAlignCenter;
			range.VerticalAlignment = XlVAlign.xlVAlignCenter;
			int num = 0;
			for (int i = 0; i < this.listViewMain.Items.Count; i++)
			{
				if (this.listViewMain.Items[i].SubItems[1].Text.Trim() != "I" && this.listViewMain.Items[i].SubItems[1].Text.Trim() != "II" && this.listViewMain.Items[i].SubItems[1].Text.Trim() != "III")
				{
					num++;
					worksheet.Cells[this.Number + 4, 1] = num.ToString();
					worksheet.Cells[this.Number + 4, 2] = this.listViewMain.Items[i].SubItems[1].Text;
					range = worksheet.get_Range("A" + (this.Number + 4).ToString(), "AH" + (this.Number + 6).ToString());
					range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
				}
				else
				{
					if (this.listViewMain.Items[i].SubItems[1].Text.Trim() == "I")
					{
						this.Number--;
						worksheet.Cells[this.Number + 4, 3] = this.listViewMain.Items[i].SubItems[1].Text;
					}
					else
					{
						worksheet.Cells[this.Number + 4, 3] = this.listViewMain.Items[i].SubItems[1].Text;
					}
					for (int j = 0; j < this.listViewMain.Columns.Count - 2; j++)
					{
						int day = DateTime.Parse(this.listDay[j]).Day;
						try
						{
							worksheet.Cells[this.Number + 4, day + 3] = this.listViewMain.Items[i].SubItems[j + 2].Text.Replace("Đi làm", "V").Replace("Vắng K.Phép", "O").Replace("Vắng C.phép", "V-").Replace("Lý do khác", "X");
						}
						catch
						{
						}
					}
				}
				this.Number++;
			}
			int num2 = 8;
			int num3 = this.Number + 3;
			range = worksheet.get_Range("A" + num2, "A" + num3);
			range.HorizontalAlignment = XlHAlign.xlHAlignCenter;
			range.VerticalAlignment = XlVAlign.xlVAlignCenter;
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("B" + num2, "B" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("C" + num2, "C" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("D" + num2, "D" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("E" + num2, "E" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("F" + num2, "F" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("G" + num2, "G" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("H" + num2, "H" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("I" + num2, "I" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("J" + num2, "J" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("K" + num2, "K" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("L" + num2, "L" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("M" + num2, "M" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("N" + num2, "N" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("O" + num2, "O" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("P" + num2, "P" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("Q" + num2, "Q" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("R" + num2, "R" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("S" + num2, "S" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("T" + num2, "T" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("U" + num2, "U" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("V" + num2, "V" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("W" + num2, "W" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("X" + num2, "X" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("Y" + num2, "Y" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("Z" + num2, "Z" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("AA" + num2, "AA" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("AB" + num2, "AB" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("AC" + num2, "AC" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("AD" + num2, "AD" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("AE" + num2, "AE" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("AF" + num2, "AF" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("AG" + num2, "AG" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("AH" + num2, "AH" + num3);
			range.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic, XlColorIndex.xlColorIndexAutomatic);
			range = worksheet.get_Range("B" + num2, "B" + num3);
			range.HorizontalAlignment = XlHAlign.xlHAlignJustify;
			range.VerticalAlignment = XlVAlign.xlVAlignCenter;
			range = worksheet.get_Range("D" + num2, "AH" + num3);
			range.HorizontalAlignment = XlHAlign.xlHAlignCenter;
			range.VerticalAlignment = XlVAlign.xlVAlignCenter;
			worksheet.get_Range("T" + (num3 + 2), "AG" + (num3 + 2)).Merge(false);
			range = worksheet.get_Range("T" + (num3 + 2), "AG" + (num3 + 2));
			range.FormulaR1C1 = string.Concat(new object[]
			{
				"Ngày ",
				DateTime.Now.Day,
				" tháng ",
				DateTime.Now.Month,
				" năm ",
				DateTime.Now.Year
			});
			range.HorizontalAlignment = XlHAlign.xlHAlignCenter;
			range.VerticalAlignment = XlVAlign.xlVAlignCenter;
			range.Font.Size = 11;
			worksheet.get_Range("B" + (num3 + 3), "I" + (num3 + 3)).Merge(false);
			range = worksheet.get_Range("B" + (num3 + 3), "I" + (num3 + 3));
			range.FormulaR1C1 = "NGƯỜI LẬP BÁO CÁO";
			range.HorizontalAlignment = XlHAlign.xlHAlignCenter;
			range.VerticalAlignment = XlVAlign.xlVAlignCenter;
			range.Font.Size = 11;
			range.Font.Bold = true;
			worksheet.get_Range("T" + (num3 + 3), "AG" + (num3 + 3)).Merge(false);
			range = worksheet.get_Range("T" + (num3 + 3), "AG" + (num3 + 3));
			range.FormulaR1C1 = "GIÁM ĐỐC";
			range.HorizontalAlignment = XlHAlign.xlHAlignCenter;
			range.VerticalAlignment = XlVAlign.xlVAlignCenter;
			range.Font.Size = 11;
			range.Font.Bold = true;
			worksheet.get_Range("B" + (num3 + 7), "AG" + (num3 + 7)).Merge(false);
			range = worksheet.get_Range("B" + (num3 + 7), "AG" + (num3 + 7));
			range.FormulaR1C1 = "Ghi chú: \"V\" - Đi làm, \"O\" - Vắng không phép, \"V-\" - Vắng có phép, \"X\" - Lý do khác";
			range.HorizontalAlignment = XlHAlign.xlHAlignLeft;
			range.VerticalAlignment = XlVAlign.xlVAlignCenter;
			range.Font.Size = 11;
			range = worksheet.get_Range("A1", "AH" + (num3 + 7));
			range.Font.Name = "Arial";
		}
		private void btnDel_Click(object sender, EventArgs e)
		{
			if (MessageBox.Show("Bạn có chắc chắn muốn xoá số liệu được chọn không?", "Cảnh báo", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
			{
				this.objPoint.delDay(this.dtpDate.Value);
				this.btnSee.PerformClick();
			}
		}
	}
}
